#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<LL, LL>;

LL k;
vector<PII> nums;

bool check(LL x){
    
    for(int i = 0; i < nums.size(); i ++){
        LL val = nums[i].first, cnt = nums[i].second;

        LL nums = 0;
        LL temp = x;
        while(temp){
            nums += temp / val;
            temp /= val;
        }

        if(nums < cnt) return false;
    }

    return true;
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> k;
    LL temp = k;
    for(LL i = 2; i <= k / i && k; i ++){
        if(k % i == 0){
            int cnt = 0;
            while(k % i == 0){
                k /= i;
                cnt ++;
            }
            nums.push_back({i, cnt});
        }
    }
    if(k > 1) nums.push_back({k, 1});

    // for(int i = 0; i < nums.size(); i ++){
    //     cout << nums[i].first << " " << nums[i].second << '\n';
    // }

    LL l = 1, r = temp;
    //cout << check(2) << '\n';
    while(l < r){
        LL mid = l + r >> 1;
  //      cout << "mid: " << mid << '\n';
        if(check(mid)){
            r = mid;
        }else{
            l = mid + 1;
        }
    }

    cout << l << '\n';


    return 0;
}